package com.kotlin.flong.oop_fp

//密封类的实现
fun main(args : Array<String>){
	var fa1 = Fater.Son2()
	var fa2 = Son5()

	println(hasRight(fa1))
	println(hasRight(fa2))

}

//sealed密封类
sealed class Fater{

	class Son1 :Fater()
	class Son2 :Fater()
	class Son3 :Fater()
	class Son4 :Fater()

}

//五个子是同父异母，不在sealed里面所以没有继承权
class Son5 :Fater()

fun hasRight (fa : Fater) : Boolean{

	return when(fa){
		is Fater.Son1 ->true
		is Fater.Son2 ->true
		is Fater.Son3 ->true
		is Fater.Son4 ->true
		else ->false
	}
}

